<template>
  <el-container style="padding: 20px;">
    <el-row :gutter="20">
      <el-col :span="24">
        <el-card class="box-card" shadow="hover">
          <h2>欢迎使用惊喜一餐！</h2>
          <p>我们为您推荐以下餐厅：</p>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col v-for="(restaurant, index) in recommendedRestaurants" :key="index" :span="8">
        <el-card class="box-card" shadow="hover">
          <img :src="restaurant.image" alt="Restaurant Image" style="width: 100%; height: 150px; object-fit: cover;" />
          <div class="text-center">
            <h3>{{ restaurant.name }}</h3>
            <el-rate :value="restaurant.rating" disabled />
            <p>{{ restaurant.description }}</p>
            <el-button @click="viewRestaurant(restaurant.id)" type="primary" size="small">查看详情</el-button>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      recommendedRestaurants: [
        { id: 1, name: '湘味木桶饭', image: 'src/image/restaurant_a.jpg', rating: 4.5, description: '精选优质食材,美味木桶饭' },
        { id: 2, name: '杨铭宇黄焖鸡', image: 'src/image/restaurant_b.jpg', rating: 4.7, description: '吃黄焖鸡首选杨铭宇' },
        { id: 3, name: '塔斯汀中国汉堡', image: 'src/image/restaurant_c.jpg', rating: 4.2, description: '只做中国汉堡' }
      ]
    }
  },
  methods: {
    viewRestaurant(id) {
      this.$router.push(`/restaurant/${id}`)
    }
  }
}
</script>
